<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!--
	本模块功能:超级管理员销户
        编写者:杨锡君
        编写时间:20180516
-->
<!DOCTYPE html>
<html class="wrap">

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<title>超级管理员销户</title>
		<link rel="stylesheet" type="text/css" href="pc/css/cores/style.css" /><!--公共样式-->
		<link rel="stylesheet" type="text/css" href="pc/css/cores/alert.css" /><!--弹出盒样式-->
		<link rel="stylesheet" type="text/css" href="pc/css/cores/public.css?f=<%=System.currentTimeMillis()%>" /><!--公共样式-->
		<style>
			.mainContent img {
				font-size: 0;
				display: initial;
				overflow: hidden;
				vertical-align: middle;
				height: 22px;
				width: 20px;
			}
			.mainContent{
				padding: 0;
			}
			.mainContent>div{
				height: 50px;
				padding:0 20px;
				margin: 0 auto;
				line-height: 50px;
			}
			.secondBox>div:nth-of-type(1){
				border-bottom: 1px solid #dfdfdf;
			}
			.secondBox a{
				font-size: 14px;
				margin-left: 180px;
				text-decoration: underline;
				color: #c82011;
			}
			.popup{
				display: block;
				width: 576px;
			}
			.popup_content {
				font-size: 16px;
				height: auto;
			}
			.popup_content>div{
				width: 265px;
				margin: 20px auto;
			}
			.popup_content>div:nth-of-type(3){
				margin-bottom: 30px;
			}
			.popup_btn .popup_close:hover{
				background: #fff;
				border: 1px solid #C80211;
				color: #c80211;
			}
		</style>
	</head>

	<body>
		<div class="crumbs">
			<div class="fl returnBox"><!-- &ensp;<img src="pc/images/ico_return.png" alt="返回按钮" />&ensp;
				<a class="looktg" href="javascript:;" onClick="javascript:window.history.go(-1)">返回上一页</a>
			 --></div>
			<div class="fl noticeBox"><img src="pc/images/ico_trumpet.png" />
				<div class="noticeBar">
					<ul>
						<li>当前暂无消息</li>
					</ul>
				</div>
			</div>
		</div>
		<div class="mb"></div>
		<div class="clear"></div>
		<div class="mainContent">
				<div>
					<img src="pc/images/ico_setTitle.png" alt="">&emsp;我的账户
				</div>
	    </div>
		<div class="mainContent secondBox">
			<div>
				<img src="pc/images/ico_setPass.png" alt="">&emsp;修改密码 <a class="passFun" href="javascript:;">修改</a>
			</div>
			<div>
				<img src="pc/images/ico_delId.png" alt="">&emsp;注销账户 <a class="delUser" href="javascript:;">注销</a>
			</div>
		</div>

        <script>
        	var result = '${result}';
        	result = JSON.parse(result);
        </script>
		<script src="pc/js/extends/jquery-1.11.2.min.js"></script>
        <script src="pc/js/cores/Alert.js"></script><!--弹出盒-->
		<script src="pc/js/cores/public.js"></script><!--公共-->
		<script>
			$(function () {
			    var $mb = $(".mb");
                var Alert1 = new Alert();
                var confirm1 = new Confirm();
                var passwordModel = "<div style='display: block' class=\"popup\">"
                    +"<div class=\"popup_box\">"
                    +"<div class=\"popup_contenthead\">修改密码<img class=\"popup_img\" src=\"pc/images/ico_alertDel.png\"></div>"
                    +"<div class=\"popup_content\">"
                    +"<div><label>&emsp;原密码&ensp;:&ensp;</label>"
					+"<input type=\"password\" name=\"password1\"  style=\"display:none\"/>"
                    +"<input autocomplete=\"off\" maxlength=\"20\" type=\"text\" onfocus=\"this.type='password'\" class=\"publicText oldPass\"/></div>"
                    +"<div><labeb>&emsp;新密码&ensp;:&ensp;</label>"
                    +"<input autocomplete=\"off\" maxlength=\"20\" type=\"text\"  onfocus=\"this.type='password'\"  class=\"publicText newPass\" /></div>"
                    +"<div><label>确认密码&ensp;:&ensp;</label>"
                    +"<input maxlength=\"20\" type=\"text\"   onfocus=\"this.type='password'\"  class=\"publicText rePass\" /></div>"
                    +"</div>"
                    +"<div class=\"popup_btn\">"
                    +"<a class=\"popup_confirm exportBtn hover-btn\">确定</a>"
                    +"<a class=\"popup_close exportCancle hover-btn\">取消</a>"
                    +"</div>"
                    +"<div class=\"clear\"></div>"
                    +"</div>"
                    +"</div>";
                // 注销
				$(".delUser").off("click").click(function () {
				    confirm1.content = "您确认注销此账号吗？";
				    confirm1.success = function () {
                        var list = [];
                        list.push(result.stuorteaId);
                        var deleteDepartmentparameters = {
                            "list": list,
                            "marks":2
                        };

                        $.ajax({
                            type: "post",
                            url: "delMembers",
                            async: true,
                            data: {
                                "jsonStr": JSON.stringify(deleteDepartmentparameters),
                                "memType":0
                            },

                            success: function(msg) {

                                var msgNew = JSON.parse(msg);

                                if(msgNew.result == "success") {
                                    Alert1.content = "注销成功";
                                    Alert1.success = function () {
                                        window.location.href = "logOut";
                                    };
                                    Alert1.init();
                                    Alert1.show();
                                } else {
                                    if(msgNew.resultMsg){
                                        Alert1.content =msgNew.resultMsg;
                                        Alert1.init();
                                        Alert1.show();
                                    }else{
                                        Alert1.content = "注销失败";
                                        Alert1.init();
                                        Alert1.show();
                                    }

                                }

                            },
                            error: function(data, status, xhr) {
                                var json = JSON.stringify({
                                    "pageName": "error"
                                });
                                window.location.href = "skipPage?jsonStr=" + json;

                            }
                        });
                    };
                    confirm1.init();
                    confirm1.show();
                });
                //			修改密码
                $(".passFun").off("click").click(function(){
                    if($(".popup").length == 0){
                        $("body").append(passwordModel);
                    }else{
                        $(".popup").show();
                    }

                    $mb.show();
                    //				X
                    $(".popup_img").off("click").click(function() {
                        $(".popup").hide();
                        $(".mb").hide();
                        $(".publicText").val("");
                    });
                    //取消
                    $(".exportCancle").off("click").click(function() {
                        $(".popup").hide();
                        $(".mb").hide();
                        $(".publicText").val("");
                    });
                    $(".exportBtn").off("click").click(function() {
                        var isOk = true;
                        var oldPass = $(".oldPass").val();
                        if(oldPass == ""){
                            Alert1.content = "请输入原密码";
                            Alert1.init();
                            Alert1.show();
                            isOk = false;
                            return false;
                        }
                        var flages = verification.spaceCode(oldPass);
                        var flagses = verification.specialCode(oldPass);
                        if(flages != true) {
                            Alert1.content = "原密码"+flages;
                            $(".oldPass").val("");
                            Alert1.init();
                            Alert1.show();
                            isOk = false;
                            return false;
                        }
                        if(flagses != true) {
                            Alert1.content = "原密码"+flagses;
                            $(".oldPass").val("");
                            Alert1.init();
                            Alert1.show();
                            isOk = false;
                            return false;
                        }
                        var newPass = $(".newPass").val();
                        if(newPass == ""){
                            Alert1.content = "请输入新密码";
                            Alert1.init();
                            Alert1.show();
                            isOk = false;
                            return false;
                        }
                        var flag = verification.spaceCode(newPass);
                        var flags = verification.specialCode(newPass);
                        if(flag != true) {
                            Alert1.content = "新密码"+flag;
                            $(".newPass").val("");
                            Alert1.init();
                            Alert1.show();
                            isOk = false;
                            return false;
                        }
                        if(flags != true) {
                            Alert1.content = "新密码"+flags;
                            $(".newPass").val("");
                            Alert1.init();
                            Alert1.show();
                            return false;
                        }
                        var rePass = $(".rePass").val();
                        if(rePass == ""){
                            Alert1.content = "请输入确认密码";
                            Alert1.init();
                            Alert1.show();
                            isOk = false;
                            return false;
                        }
                        if(newPass != rePass){
                            Alert1.content = "两次密码输入不一致请重新输入";
                            Alert1.init();
                            Alert1.show();
                            isOk = false;
                            return false;
                        }
                        var jsonStr = JSON.stringify({
                            "befPassword":oldPass,
                            "password":newPass
                        });
                        if(isOk){
                            $.ajax({
                                type:"post",
                                url:"forgetPasswordSubmit",
                                async:true,
                                data:{
                                    "jsonStr":jsonStr
                                },
                                success:function(msg){
                                    msg = JSON.parse(msg);
                                    if(msg.result == "success"){
                                        Alert1.content = "密码修改成功";
                                        Alert1.success = function(){
                                            $mb.hide();
                                            $(".popup").remove();
                                            window.location.href = "logOut";
                                        };
                                        Alert1.init();
                                        Alert1.show();
                                    }else{
                                        Alert1.content = msg.msg;
                                        Alert1.init();
                                        Alert1.show();
                                        if($(".popup").length == 0){
                                            $("body").append(passwordModel);
                                        }else{
                                            $(".popup").show();
                                        }
                                        $mb.show();
                                    }
                                }
                            });
                        }

                    });
                });
                    maxLengthLimit.init("publicText");
                });

		</script>
	</body>

</html>
